from odoo import api, fields, models, _
import logging
from odoo.exceptions import UserError

logger = logging.getLogger(__name__)

class InfoMER_Recover(models.Model):
    _name = 'user.recover'
    _description = 'user_info'

    number_no = fields.Char(
        '患者编号',
        index=True,
        readonly=True,
        default='自动生成'
    )
    #
    # @api.model
    # def create(self, vals):
    #     """
    #     自动生成单号
    #     :return:
    #     """
    #     vals['number_no'] = self.env['ir.sequence'].next_by_code('user.info') or ''
    #     return super(InfoMER, self).create(vals)

    name = fields.Char(
        '姓名',
        required=True,
    )
    member_image = fields.Binary(
        string='头像'
    )
    vaccine_sex = fields.Selection(
        [
            ('001', '男'),
            ('002', '女')
        ],
        '性别',
        default='001',
    )
    vaccine_nation = fields.Char(
        '民族',
        required=True,
        default='汉族',
    )
    vaccine_phone = fields.Char(
        '电话',
        required=True,
    )
    vaccine_email = fields.Char(
        '邮箱地址',
    )
    vaccine_stature = fields.Float(
        '身高(cm)',
    )
    vaccine_weight = fields.Float(
        '体重(kg)',
    )
    vaccine_adverseevent = fields.Selection(
        [
            ('001', '有'),
            ('002', '无'),
            ('003', '不详')
        ],
        '既往接种疫苗是否有不良反应与事件',
        default='001',
    )
    vaccine_family = fields.Selection(
        [
            ('001', '有'),
            ('002', '无'),
            ('003', '不详')
        ],
        '家族成员既往接种疫苗是否有不良反应与事件',
        default='001',
    )
    vaccine_medical = fields.Selection(
        [
            ('001', '肝病史'),
            ('002', '肾病史'),
            ('003', '过敏史'),
            ('003', '其他')
        ],
        '存在病史',
        default='001',
    )
    vaccine_inoculate = fields.Selection(
        [
            ('001', '百白破疫苗'),
            ('002', '乙肝疫苗'),
            ('003', '卡介疫苗'),
            ('004', '脊髓灰质疫苗'),
            ('005', '麻疹疫苗'),
            ('006', '狂犬病疫苗'),
            ('007', 'HPV疫苗'),
        ],
        '曾经接种过的疫苗',
        default='001',
    )
    color = fields.Integer()
    sequence = fields.Integer(string='Sequence')
    status = fields.Selection(
        [('默认', '默认'),
         ('康复', '康复'),
         ('特殊', '特殊')],
        '状态',
        default='康复')
